#ifndef STATEPATTERN_H
#define STATEPATTERN_H

#include "state.h"
#include "../manager.h"
#include "../eventmanager.h"
#include "../parammanager.h"
#include "../route.h"
#include "../properties.h"

namespace state {


struct Pattern : public State {
	Pattern(int id) : State(id) {}
	
	virtual void onEnter() {
		//Manager::Instance().getRoute()->flyToPattern();
		
		ParamManager *parammgr = Manager::Instance().getParamManager();		
		
		PropAccessor p;
		p().fcs.roll.set(Roll_Track, 30);
		p().fcs.pitch.set(Pitch_Track);
		//p().fcs.pitch.set(Pitch_Airspeed, parammgr->getFloat(ParamManager::VCRUISE) / 3.6f);
		//p().fcs.track.fromAlt = p().air_data.altitude_est;
		//p().fcs.track.toAlt = p().air_data.altitude_est;
		p().fcs.yaw.set(Yaw_Damper);
		p().fcs.throttle.set(Throttle_Airspeed, parammgr->getFloat(ParamManager::VCRUISE) / 3.6f);
		//p().fcs.throttle.set(Throttle_Track, parammgr->getFloat(ParamManager::VCRUISE) / 3.6f);
		p().fcs.flaps.set(Flaps_Value, Flaps_Value_Retracted);
		p().fcs.brakes.set(Brakes_Value, 0);

		p().fcs.watcher = Watcher_Idle;

		p().fcs.parachute_armed = true;
		
		p().fcs.state = getId();
	}
};

}

#endif
